﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>02_还记得点线面吗</title>
    <script src="../js/three.js"></script>
</head>
<body>
    <script>
        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        var renderer = new THREE.WebGLRenderer({
            antialias: true
        });
        renderer.setSize(window.innerWidth, window.innerHeight);
        document.body.appendChild(renderer.domElement);

        var light = new THREE.DirectionalLight(0xffffff);
        light.position.set(10, 10, 10);
        scene.add(light);

        var geometry = new THREE.Geometry();
        geometry.vertices.push(new THREE.Vector3(-5, 0, 0));
        geometry.vertices.push(new THREE.Vector3(5, 0, 0));
        geometry.colors.push(new THREE.Color(0xff0000));
        geometry.colors.push(new THREE.Color(0x00ff00));
        var material = new THREE.LineBasicMaterial({ vertexColors: true });
        var line = new THREE.Line(geometry, material);
        scene.add(line);

        geometry = new THREE.Geometry();
        geometry.vertices.push(new THREE.Vector3(0, 0, 0));
        geometry.vertices.push(new THREE.Vector3(0, 5, 0));
        geometry.vertices.push(new THREE.Vector3(5, 5, 0));
        var material = new THREE.PointsMaterial({ color: 0xff0000 });
        var point = new THREE.Points(geometry, material);
        scene.add(point);

        camera.position.set(0, 0, 20);
        camera.lookAt(0, 0, 0);

        renderer.render(scene, camera);
    </script>
</body>
</html>
